package com.zut.blocks.base.common.request;

import com.zut.blocks.base.common.CommonRequest;
import com.zut.blocks.base.domain.Grade;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.ExampleMatcher;

/**
 * @author lxd
 * @date 2020/12/6 22:28
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class GradeRequest extends CommonRequest {

    private Integer studentId;
    private Integer courseId;

    public Example<Grade> example() {
        Grade grade = new Grade();
        grade.setStudentId(studentId);
        grade.setCourseId(courseId);
        return Example.of(grade, ExampleMatcher
                        .matching()
                        .withMatcher("studentId", ExampleMatcher.GenericPropertyMatchers.exact())
                        .withMatcher("courseId", ExampleMatcher.GenericPropertyMatchers.exact()));

    }
}
